<template>
  <div>
    <div>
      <div style="text-align: center; margin: 10px">
        {{ form.CheckTaskName }}
      </div>
      <div class="block-box">
        <div class="block-box_item">
          <eagle-cell-group :border="border">

            <eagle-input 
              label="检查类型"
              :value="
                form.CheckTypeName +
                (form.CheckType == 'ZCLX0002'
                  ? '(' + form.ItemTypeName + ')'
                  : '')
              "
              readonly
            ></eagle-input>

            <eagle-input
              label="检查企业"
              autosize
              type="textarea"
              rows="1"
              v-if="form.CPID == null"
              :value="form.EnterpriseName"
              readonly
              islink
              @click="goFromDeta()"
            ></eagle-input>

            <eagle-input
              label="检查人"
              :value="form.CheckNames"
              readonly
            ></eagle-input>

            <eagle-input
              label="检查时间段"
              :value="form.StartDate + '至' + form.EndDate"
              autosize
              type="textarea"
              rows="1"
              readonly
            ></eagle-input>

            <eagle-input
              label="创建人"
              :value="form.CreateChnName"
              readonly
            ></eagle-input>

            <eagle-input
              label="创建日期"
              :value="form.CreateDate"
              readonly
            ></eagle-input>

            <eagle-input
              label="提交日期"
              :value="form.CreateDate"
              readonly
            ></eagle-input>

            <eagle-input
              label="状态"
              :value="'已提交/待验收'"
              readonly
            ></eagle-input>

             <eagle-input
            
              label="隐患记录"
              :value="
                form.HiddenDangerCnt 
              "
              readonly
              islink
              @click="goTaskHiddenDanger()"
            ></eagle-input>
            
          </eagle-cell-group> 
        </div>
      </div>
      
      <div class="btns m-10">
        <eagle-button style="flex:1;" type="green2"  @click="ReassignmentTask()">保存任务</eagle-button>
      </div>

    </div>



    <Departmentuser
        :show.sync="DepartmentTypeShow"
        @callback="_userchoosePeople"
        :selectedValue="this.form.CorrectiveDeptCode"
        >
    </Departmentuser>


  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";
import { mapGetters } from "vuex";
import Departmentuser from "../FeedSafetyProduction/userPeopleChooseDialog.vue";
export default {
  components: {
		Departmentuser,
	},
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      id: this.$route.query.id,
      isDate: true,
      border: false,
      openType : "TaskEdit",
      DepartmentTypeShow: false,
      filter: {
        id : this.$route.query.TaskId,
      },
      form: {
        Templates: [],
      },
    };
  },
  computed: {
    ...mapGetters(["CompanyCode"]),
  },
  created() {
    this.isDate = this.$route.query.isDate;
    this.geDetail();
  },
  methods: {
    // 上传图片
    goMyTaskFileList(imgType) {
      this.$router.push(
        "/OtherDanger/DangerCheckTaskFileList?ctCode=" + this.form.CTCode + "&type=" + imgType
      );
    },

    // 检查记录
    goMyTaskHistoryList() {
      this.$router.push({
        path: "/OtherDanger/CheckPlanHistoryList",
        query: {
          ctCode: this.form.CTCode,
        },
      });
    },

    // 待验收隐患
    goMyTaskyinhuan() {
        this.$router.push({
        path: "/OtherDanger/DangerCheckTaskDetailVerifyList",
        query: {
          ctCode: this.form.CTCode,
        },
      });
    },



    		// 选择部门
		_goCheckTaskPeople(backpath) {
			
			this.DepartmentTypeShow = true
		},
		// 选择部门回调
		_userchoosePeople(item) {
			if (item) {
				this.$set(this.form, 'CorrectiveDeptName', item.name)
				this.form.CorrectiveDeptCode = item.code

				this.DepartmentTypeShow = false
			}
		},

    // 获取详情
    geDetail() {
      let that = this;
      that.$axios
      .get("/OtherDangerCheckTaskJG/GetDetail",{params:that.filter})
      .then((res) => {
        that.form = res.data;
        that.form.StartDate = getDateTime(this.form.StartDate);
        that.form.EndDate = getDateTime(this.form.EndDate);
        that.form.CreateDate = getDateTime(this.form.CreateDate);
      });
    },


    goFromDeta() {
      this.$router.push("/BaseInfo?CompanyCode=" + this.form.EnterpriseCode);
    },

    // 跳转隐患页面
    goTaskHiddenDanger() {
      this.$router.push({
        path: "/FeedSafetyProduction/feedhiddendanger",
        query: {
          ctCode: this.form.CTCode,
          openType : this.openType
        },
      });
    },

    //  部门指派保存
    ReassignmentTask() {
      let that = this;
      let params = {
        ctCode : that.form.CTCode
      }
      this.$dialog.confirm({
        title: "询问",
        message: "您确定要提交当前检查任务吗?",
      })
        .then(() => {
          
          this.$axios
            .get('/ChsDangerNotPorduce/SaveTaskEntity', {
              params: params,
            })
            .then((res) => {
              that.$toast("保存成功");
              this.$router.push({
                path: "/FeedSafetyProduction/List",
              })
            });
        })
    },
  },
};
</script>

<style lang="less" scoped>
/*
        .main {
            height: 100vh;
        }
    */
.bottom-btns {
  margin-top: 10px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .submit-btn {
    width: 32%;
    height: 35px;
    font-size: 14px;
  }
  .delete-btn {
    width: 100%;
    height: 35px;
    font-size: 14px;
  }
}
.det_top_box {
  padding: 10px;
  background-color: #e8f1f8;
}

.detail_header {
  color: #ffffff;
  background: url("../../../assets/Images/AppIcon/image_riskunit_detail_bg.png");
  background-size: cover;
  padding: 10px;
  border-radius: 5px;
  /*background-color: #fff;*/

  .det_top {
    display: flex;
    justify-content: space-between;

    .dep_top_img {
      height: 20px;
      width: 20px;
      margin-right: 5px;
    }
  }

  .det_name {
    margin-top: 20px;
    text-align: center;
  }

  .det_location {
    text-align: center;
    margin-bottom: 20px;
  }
}

.det_tab {
  padding: 10px;
  .det_tab_item {
    padding: 10px 0;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;

    .det_tab_item_text {
      padding: 0 10px;
    }
  }
}
.text_box {
  padding: 10px;
  border-radius: 5px;
  /*background-color: #e8f1f8;*/
  margin-bottom: 10px;

  .text_top {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .top_link {
      color: #1989fa;
    }
  }

  .text_item {
    display: flex;
    justify-content: space-between;
    margin-left: 10px;

    .item_link {
      color: #1989fa;
    }
  }

  .text_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      img {
        height: 25px;
        width: 25px;
        margin-bottom: 10px;
      }
    }
  }

  .text_history {
    display: flex;
    vertical-align: middle;
    margin-bottom: 10px;
  }

  .text_member {
    color: #1989fa;
    margin-bottom: 10px;
  }

  .text_total_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      .img_item_top {
        display: flex;
        vertical-align: middle;
        margin-bottom: 10px;
      }
      img {
        height: 15px;
        width: 15px;
        margin-right: 5px;
      }
    }
  }
  .text_record_list {
    .list_row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      > div {
        width: 33.3%;
      }
      .row_center {
        text-align: center;
      }
      .row_right {
        text-align: right;
      }
    }
  }
}
.operate_list {
  font-size: 12px;
  border: 1px solid #e8f1f8;
  .operate_row_first {
    padding: 10px;
    background-color: #e8f1f8;
    border-bottom: 1px solid #e8f1f8;
    margin-bottom: 10px;
  }
  .operate_row {
    padding: 10px;
    border-bottom: 1px solid #e8f1f8;
    /*margin-bottom: 10px;*/
  }
}
  .mls{
    margin-right: 5px;
  }
</style>
